package Text11;
import java.util.*;
public class Main {
    static int N=110;
    static int[][] v=new int[N][N];
    static int[][] w=new int[N][N];
    static int[] f=new int[N];
    static int[] s=new int[N];

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n=in.nextInt();
        int m=in.nextInt();
        for (int i = 1; i <=n ; i++) {
             s[i]=in.nextInt();
            for (int j = 1; j <=s[i] ; j++) {
                v[i][j]=in.nextInt();
                w[i][j]=in.nextInt();
            }
        }

        for (int i = 1; i <=n ; i++) {
            for (int j = m; j>=1 ; j--) {
                for (int k = 0; k <=s[i] ; k++) {
                    if(j>=v[i][k]){
                        f[j]=Math.max(f[j],f[j-v[i][k]]+w[i][k]);
                    }
                }
            }
        }
        System.out.println(f[m]);
    }
}
